#ifndef MOBILESTORAGELISTVIEW_H
#define MOBILESTORAGELISTVIEW_H

#include <QListView>
#include <QStandardItemModel>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
#include <QMenu>
#include <QAction>
#include "mobilestoragelistdelegate.h"
#include "fileinfo.h"
#include "copytocomputerbuttonwidget.h"

class MobileStorageListView : public QListView
{
    Q_OBJECT
public:
    explicit MobileStorageListView(QWidget *parent = nullptr);
    ~MobileStorageListView();

    //默认图标模式
    void setViewModeFlag(QListView::ViewMode mode);
    void setResize();
    void setFileList(const QMap<QString, FileInfo> &listStruct);
    //获取选择项文件名列表（不包括文件夹）
    void selectAllNames(QList<FileInfo> &fileList);
private Q_SLOTS:
    void slotDoubleClicked(const QModelIndex &index);
    void slotPressed(const QModelIndex &index);
    void slotContextMenu(const QPoint &pos);
    void slotOpenTriggered();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
Q_SIGNALS:
    void signalSetResize(int height);
    void sigFileName(QString fileNamePath);
    void sigShowCopyButton();
    void sigHideCopyToComputerWidget();
    void sigSelectDataList(const QList<FileInfo> &nameList);
    void sigMousePress(QMouseEvent *event);
    void sigMouseRelease();
    void sigSelectAll();
    void sigMenuFileName(QString fileName);

private:
    //设置图形模式高度
    void setWidgetIconItemHeight();
    //设置列表模式高度
    void setWidgetListItemHeight();
    void initMenuAction();
    QString getSize(qint64 sizeByte);
    //区分是图片还是视频...
    //    QString m_currentListName;
    MobileStorageListDelegate *m_listDelefate = nullptr;
    QStandardItemModel *m_listModel = nullptr;
    int m_height = 0;
    QMenu *m_menu = nullptr;
    QAction *m_openAction = nullptr;

    QList<FileInfo> m_fileInfo;
    int m_systemFontHeight;
};

#endif // MOBILESTORAGELISTVIEW_H
